<template>
  <a-card :bordered="false">
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('sysDepartBankInfo:add')">新增</a-button>
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <!-- <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel" :disabled="isDisabledAuth('sysDepartBankInfo:delete')"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>



    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
            <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="edit"
              :hidden="disabled"
              @click="handleEdit(record)"
              :disabled="isDisabledAuth('sysDepartBankInfo:edit')"
            />
        <a-divider type="vertical" :hidden="disabled"/>
        <a-popconfirm title="确定删除吗?" :hidden="disabled" @confirm="() => handleDelete(record.id)">
            <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="delete"
              :disabled="isDisabledAuth('sysDepartBankInfo:delete')"/>
        </a-popconfirm>
        </span>

      </a-table>
    </div>

    <sys-depart-bank-info-modal ref="modalForm" @ok="modalFormOk" ></sys-depart-bank-info-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import SysDepartBankInfoModal from './SysDepartBankInfoModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import AuditModal from '@/views/scy/components/AuditModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction,postAction } from '@/api/manage'


export default {
  name: 'SysDepartBankInfoList',
  mixins: [JeecgListMixin,mixinDevice, DisabledAuthFilterMixin],
  components: {
    SysDepartBankInfoModal,
    AuditModal,
  },
  props: {
      // 表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
    },
  data() {
    return {
      departId:"",
      description: '银行卡信息管理页面',
      //表头
      columns: [],
      //列设置
      settingColumns: [],
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '开户行',
          align: 'center',
          dataIndex: 'openingBank',
        },
        {
          title: '银行账户',
          align: 'center',
          dataIndex: 'bankCardNo',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      url: {
        list: '/api/erpmng/sys/sysDepartBankInfo/list',
        delete: "/api/erpmng/sys/sysDepartBankInfo/delete",
        deleteBatch: "/api/erpmng/sys/sysDepartBankInfo/deleteBatch",
      },
      dictOptions: {},
      superFieldList: [],
      disableMixinCreated: true
      
    }
  },
  created() {
    this.getSuperFieldList();
    this.initColumns()
  },
  computed: {
  },
  methods: {
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      // 加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = {departId:this.departId};
      this.loading = true
      getAction(this.url.list, params).then(res => {
        if (res.success) {
          // update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          this.dataSource = res.result.records || res.result
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
          //判断是否当前页没有数据且不为第一页
          if (this.dataSource.length == 0 && this.ipagination.current != 1) {
            this.ipagination.current = this.ipagination.current - 1
            this.loadData(this.ipagination.current - 1);
          }
          // update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        } else {
          this.dataSource = [];
          this.ipagination.total = 0
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
    show(depart){
      this.departId=depart;
      this.loadData();
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'bankCardNo', text: '银行账户', dictCode: '' })
      this.superFieldList = fieldList
    },
    handleAdd: function () {
      this.$refs.modalForm.add(this.departId)
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
